.SUFFIXES: .c .o

COMPILE = $(CC) $(CFLAGS)
INC_PATH = -I/usr/local/include -I.. -I../common
LIB_PATH = $(LIBS) -lm -ldl -lfastcommon -lserverframe -lfcfsauthclient \
           -lfcfsvoteclient -ldiskallocator
TARGET_PATH = $(TARGET_PREFIX)/bin
CONFIG_PATH = $(TARGET_CONF_PATH)

COMMON_OBJS = ../common/fs_proto.o ../common/fs_global.o \
              ../common/fs_cluster_cfg.o

CLIENT_OBJS = ../client/fs_client.o ../client/client_func.o \
              ../client/client_global.o ../client/client_proto.o \
              ../client/simple_connection_manager.o

SERVER_OBJS = server_func.o service_handler.o cluster_handler.o \
              replica_handler.o common_handler.o data_update_handler.o \
              server_global.o server_group_info.o server_storage.o \
              storage/object_block_index.o storage/slice_op.o \
              storage/committed_version.o storage/slice_space_log.o \
              binlog/binlog_func.o  binlog/binlog_reader.o \
              binlog/binlog_read_thread.o binlog/binlog_loader.o \
              binlog/slice_binlog.o  binlog/slice_loader.o  \
              binlog/replica_binlog.o binlog/binlog_check.o \
              binlog/binlog_repair.o binlog/migrate_clean.o \
              binlog/replica_clean.o binlog/slice_clean.o   \
              binlog/slice_dedup.o binlog/binlog_rollback.o \
              binlog/slice_dump.o binlog/trunk_migrate.o \
              binlog/slice_space_migrate.o binlog/db_remove.o  \
              binlog/marked_reader.o  \
              replication/replication_processor.o \
              replication/replication_common.o    \
              replication/replication_caller.o    \
              replication/replication_callee.o    \
              replication/replication_quorum.o server_binlog.o \
              server_replication.o cluster_relationship.o cluster_topology.o \
              data_thread.o shared_thread_pool.o master_election.o \
              server_recovery.o recovery/binlog_fetch.o recovery/binlog_sync.o \
              recovery/binlog_dedup.o recovery/binlog_replay.o \
              recovery/data_recovery.o recovery/recovery_thread.o \
              rebuild/store_path_rebuild.o rebuild/rebuild_binlog.o \
              rebuild/binlog_spliter.o rebuild/rebuild_thread.o \
              db/change_notify.o db/block_serializer.o db/event_dealer.o \
              db/db_updater.o


ALL_OBJS = $(COMMON_OBJS) $(CLIENT_OBJS) $(SERVER_OBJS)

ALL_PRGS = fs_serverd

all: $(ALL_PRGS)

$(ALL_PRGS): $(ALL_OBJS)

.o:
	$(COMPILE) -o $@ $<  $(LIB_PATH) $(INC_PATH)
.c:
	$(COMPILE) -o $@ $<  $(ALL_OBJS) $(LIB_PATH) $(INC_PATH)
.c.o:
	$(COMPILE) -c -o $@ $<  $(INC_PATH)

install:
	mkdir -p $(TARGET_PATH)
	cp -f $(ALL_PRGS) $(TARGET_PATH)
clean:
	rm -f *.o $(ALL_OBJS) $(ALL_PRGS)
